<template>
  <div class="h-screen flex w-full flex-col items-center">
    <navbar></navbar>
    <router-view class="mt-20"></router-view>
    <!-- <contents class="mt-20"></contents> -->
  </div>
</template>
<script>
// import Navbar from '../components/Navbar'
import Navbar from "../components/Navbar.vue";
import { requests } from "../network/request";
// import Content from '../components/Content.vue'

export default {
  name: "Home",
  data() {
    return {};
  },
  components: {
    // Navbar
    Navbar,
    // 'contents': Content
  },
  methods: {},
  mounted: function () {
    // alert("Hello");
    //获取当前用户
    requests({
      url: "dquser/getnowuser",
      method: "get",
    }).then((res) => {
      console.log(res);
      if (res.data.code == 200) {
        console.log("用户已登陆");
        // 写入数据
        this.$store.commit("updateDqUser", res.data.data);
      }
    });

    // 获取用户文章文章数量
    requests({
      url: "number/dqarticlenumbynowuser",
      method: "get",
    }).then((res) => {
      if (res.data.code == 200) {
        //写入
        this.$store.commit("updateArticleNum", res.data.data);
      }
    });

    // 获取用户文章评论数量
    requests({
      url: "number/dqcommentnumbynowuser",
      method: "get",
    }).then((res) => {
      if (res.data.code == 200) {
        //写入
        this.$store.commit("updateCommentNum", res.data.data);
      }
    })
    //获得所有的文章标签
    requests({
      url: 'dqtag/list',
      method: 'get'
    }).then(res => {
      // console.log("所有的文章标签"+res.data.data.list);
      //写入
      this.$store.commit("updateArticleTags",res.data.data.list)
    })
  },
};
</script>
<style scoped>
</style>